package cn.iocoder.yudao.module.infra.controller.admin.ocr.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.util.List;

@Schema(description = "Admin - OCR Recognition Response VO")
@Data
public class OcrRecognizeRespVO {

    @Schema(description = "Record ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long recordId;

    @Schema(description = "Recognition status: 0-Failed, 1-Success", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer status;

    @Schema(description = "OCR recognition result (JSON format)", requiredMode = Schema.RequiredMode.REQUIRED)
    private String result;

    @Schema(description = "Error message (when recognition fails)", example = "API key invalid")
    private String errorMsg;

    @Schema(description = "Processing time (milliseconds)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1500")
    private Long processTime;

    // 新增前端期望的字段
    @Schema(description = "Recognized text content", example = "Hello World")
    private String text;

    @Schema(description = "Overall confidence score", example = "0.95")
    private Double confidence;

    @Schema(description = "Detailed word recognition results")
    private List<WordResult> words;

    @Schema(description = "Structured field recognition results")
    private List<FieldResult> fields;

    @Schema(description = "Word recognition result")
    @Data
    public static class WordResult {
        @Schema(description = "Recognized text", example = "Hello")
        private String text;

        @Schema(description = "Confidence score", example = "0.98")
        private Double confidence;

        @Schema(description = "Text location")
        private Location location;
    }

    @Schema(description = "Field recognition result")
    @Data
    public static class FieldResult {
        @Schema(description = "Field name", example = "姓名")
        private String fieldName;

        @Schema(description = "Field value", example = "张三")
        private String fieldValue;

        @Schema(description = "Confidence score", example = "0.95")
        private Double confidence;
    }

    @Schema(description = "Text location coordinates")
    @Data
    public static class Location {
        @Schema(description = "Left coordinate", example = "100")
        private Integer left;

        @Schema(description = "Top coordinate", example = "50")
        private Integer top;

        @Schema(description = "Width", example = "200")
        private Integer width;

        @Schema(description = "Height", example = "30")
        private Integer height;
    }

}